package com.zyy.service.controller;

import com.zyy.api.pojo.LabelInfo;
import com.zyy.api.pojo.LabelNewsInfo;
import com.zyy.service.service.LabelResultService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 *@author zhangyangyang
 *@createTime 2023417 10:40
 *@description 打标服务对外接口
 */
@RestController
@RequestMapping("label")
@Validated
@Slf4j
public class ServiceController {

    @Autowired
    private LabelResultService labelResultService;

    @PreAuthorize("hasAuthority(T(com.zyy.security.config.PermissionEnum).PERMISSION_DATA_INTERFACE)")
    @PostMapping(value = "/analysisLabel", produces = MediaType.APPLICATION_JSON_VALUE,consumes = MediaType.APPLICATION_JSON_VALUE)
    public List<LabelInfo> analysisLabel(@Valid @RequestBody LabelNewsInfo info) {
        log.info("标签解析请求 {}", info);
        return labelResultService.analysisLabelResult(info);
    }

}
